package com.cg.service.impl;

import com.cg.dao.DepartmentMapper;
import com.cg.dto.DepartmentDto;
import com.cg.entity.Department;
import com.cg.service.DepartmentService;
import com.cg.vo.DepartmentVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Department)表服务实现类
 *
 * @author chengong
 * @since 2023-12-01 09:16:22
 */
@Service("departmentService")
public class DepartmentServiceImpl implements DepartmentService {
    @Resource
    private DepartmentMapper departmentMapper;


    /**
     * 查询部门表信息全部信息
     * @return
     */
    @Override
    public List<Department> queryAll() {
        return departmentMapper.queryAll();
    }

    @Override
    public PageInfo<DepartmentVo> queryDepByDepName(DepartmentDto departmentDto) {
        PageHelper.startPage(departmentDto.getPageNum(),departmentDto.getPageSize());
        List<DepartmentVo> departments = departmentMapper.queryDepByDepName(departmentDto.getDepName());
        PageInfo<DepartmentVo> departmentPageInfo = new PageInfo<>(departments);
        return departmentPageInfo;
    }
}
